export const initForm = () => {
  return {
    roleIds: [],
    shipId: ""
  }
}

export const rules = {
  username: [
    { required: true, message: "必填", trigger: "blur" }
  ],
  usedeptIdrname: [
    { required: true, message: "必填", trigger: "change" }
  ],
  phone: [
    { required: true, message: "必填", trigger: "blur" }
  ],
  password: [
    { required: true, message: "必填", trigger: "blur" }
  ],
  roleIds: [
    { required: true, message: "必填", trigger: "change" }
  ],
  userType: [
    { required: true, message: "必填", trigger: "change" }
  ],
  shipId: [
    { required: true, message: "必填", trigger: "change" }
  ],
  nickname: [
    { required: true, message: "必填", trigger: "blur" }
  ],
}

export const initSearchForm = () => {
  return {
    current: 1,
    size: 10,
    userName: undefined,
    phonenumber: undefined,
    status: undefined,
    deptId: undefined
  }
}

export const statusOptions = [
  {
    label: "正常",
    value: 0
  }, {
    label: "锁定",
    value: 1
  }
]

export const getDeptName = (id, list) => {
  if (id === "-1" && !id) return ""
  let DeptName = ""
  let fn = (id, data) => {
    for (let item of data) {
      if (item.id === id) {
        DeptName = item.deptName
        return false
      }
      if (item.children && item.children.length > 0) {
        fn(id, item.children)
      }
    }
  }
  fn(id, list)
  return DeptName
}

export const initPermitForm = () => {
  return {
    current: 1,
    size: 10,
  }
}